#set( $symbol_pound = '#' )
#set( $symbol_dollar = '$' )
#set( $symbol_escape = '\' )
package ${package};

import java.util.Collections;

import com.networknt.config.JsonMapper;

import io.undertow.server.HttpHandler;
import io.undertow.server.HttpServerExchange;
import io.undertow.util.Headers;

public class JsonHandler implements HttpHandler {

	public void handleRequest(HttpServerExchange exchange) throws Exception {
		answerJson(exchange, Collections.singletonMap("message", "Hello World"));
	}

	public static void answerJson(HttpServerExchange exchange, Object obj) throws Exception {
		exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, "application/json");
		exchange.getResponseSender().send(JsonMapper.objectMapper.writeValueAsString(obj));
	}
}
